package com.chrudgames.stayintouch;

import java.util.Calendar;

import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

public class SetAlarm extends Service {
	
     
     @Override
     public IBinder onBind(final Intent intent) {
      return null;
     }
     
     @Override
     public void onCreate() {
      super.onCreate();

     }
     
     @Override
     public void onStart(final Intent intent, final int startId) {
      super.onStart(intent, startId);
	 Calendar cal = Calendar.getInstance();
	 
     cal.add(Calendar.HOUR, 1 );       
     //Create a new PendingIntent and add it to the AlarmManager
     Intent intentSet = new Intent(this, AlarmReceiverActivity.class);
     PendingIntent pendingIntent = PendingIntent.getActivity(this,
         12345, intentSet, PendingIntent.FLAG_CANCEL_CURRENT);
     AlarmManager am =
         (AlarmManager)this.getSystemService(Activity.ALARM_SERVICE);


     am.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), AlarmManager.INTERVAL_DAY, 
             pendingIntent);

     this.stopSelf();
     
     }
    }
     

